<template>
    <div class="app-container" v-loading.fullscreen.lock="fullLoading">

        <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="68px">
            <el-form-item label="学院" prop="deptId">
                <el-select size="mini" @change="changeSearchDept" v-model="queryParams.deptId" placeholder="学院"
                    clearable>
                    <el-option v-for="(v, i) in dept_list" :key="i" :label="v.label" :value="v.value" />
                </el-select>
            </el-form-item>
            <el-form-item label="专业" prop="majorId">
                <el-select @change="changeSearchMajor" v-model="queryParams.majorId" placeholder="请先选择学院再选择专业"
                    filterable clearable>
                    <el-option v-for="(v, i) in search_major_list" :key="i" :label="v.majorName" :value="v.majorId">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="班级" prop="classId">
                <el-select v-model="queryParams.classId" placeholder="请先选择专业再选择班级" filterable clearable>
                    <el-option v-for="(v, i) in search_class_list" :key="i" :label="v.className" :value="v.classId">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="学号" prop="stuNo">
                <el-input v-model="queryParams.stuNo" placeholder="请输入学号" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="学生姓名" prop="stuName">
                <el-input v-model="queryParams.stuName" placeholder="请输入学生姓名" clearable
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="奖项" prop="code">
                <el-select v-model="queryParams.code">
                    <el-option v-for="(v, i) in code_list" :key="i" clearable :value="v.code"
                        :label="v.name"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="审核状态" prop="status">
                <el-select size="mini" v-model="queryParams.status" placeholder="审核状态" clearable>
                    <el-option v-for="(v, i) in applyStatus" :key="i" :label="v.label" :value="v.value" />
                </el-select>
            </el-form-item>
            <el-form-item label=" ">
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini"
                    @click="jxjVClick">导出学业奖学金名单</el-button>
                <el-button type="warning" plain icon="el-icon-download" size="mini"
                    @click="shxsVClick">导出三好学生名单</el-button>
                <el-button type="warning" plain icon="el-icon-download" size="mini"
                    @click="yxbgVClick">导出优秀学生干部名单</el-button>
            </el-col>
        </el-row>

        <el-table v-loading="loading" :data="table_data">
            <el-table-column label="奖项" prop="typeName" align="center" width="120px" />
            <el-table-column label="学号" prop="stuNo" align="center" width="120px" />
            <el-table-column label="学生" prop="stuName" align="center" width="100px" />
            <el-table-column label="专业" prop="majorName" align="center" />
            <el-table-column label="班级" prop="className" align="center" />
            <el-table-column label="申请状态" align="center" width="120px">
                <template slot-scope="scope">
                    <dict-tag :options="dict.type.audius_detail_type" :value="scope.row.applyStatus" />
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="120px">
                <template slot-scope="scope">
                    <el-button type="text" size="mini" icon="el-icon-view"
                        @click="auditVClick(scope.row)">查看详情</el-button>
                    <el-button type="text" size="mini" icon="el-icon-delete"
                        @click="voidVClick(scope.row)">作废</el-button>
                    <el-button type="text" size="mini" icon="el-icon-edit"
                        @click="changeVClick(scope.row)">修改状态</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />

        <el-dialog title="申请" :visible.sync="auditV" fullscreen :close-on-click-modal="false">
            <el-form class="detail" label-width="160px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="班级">
                            <el-input readonly size="mini" v-model="auditForm.className"
                                class="auditForm-input"></el-input>
                        </el-form-item>
                        <el-form-item label="姓名">
                            <el-input readonly size="mini" v-model="auditForm.stuName"
                                class="auditForm-input"></el-input>
                        </el-form-item>
                        <el-form-item label="奖项">
                            <el-input readonly size="mini" v-model="auditForm.typeName"
                                class="auditForm-input"></el-input>
                        </el-form-item>
                        <el-form-item label="政治面貌">
                            <el-input readonly size="mini" class="auditForm-input" v-model="auditForm.zzmm"></el-input>
                        </el-form-item>
                        <el-form-item label="职务">
                            <el-input readonly size="mini" class="auditForm-input"
                                v-model="auditForm.classPost"></el-input>
                        </el-form-item>
                        <el-form-item v-if="!isEmpty(auditForm.classtwoSure)" label="第二课堂学分认定">
                            <el-input readonly size="mini" class="auditForm-input"
                                v-model="auditForm.classtwoSure"></el-input>
                        </el-form-item>
                        <!-- <el-form-item v-if="!isEmpty(auditForm.youthPercent)" label="青年大学习学习率">
                            <el-input readonly size="mini" class="auditForm-input"
                                v-model="auditForm.youthPercent"></el-input>
                        </el-form-item> -->
                        <el-form-item v-if="!isEmpty(auditForm.bankCard)" label="中国农业银行银行卡号">
                            <el-input readonly size="mini" class="auditForm-input"
                                v-model="auditForm.bankCard"></el-input>
                        </el-form-item>
                        <el-form-item v-if="!isEmpty(auditForm.bankAddr)" label="开户行">
                            <el-input readonly size="mini" class="auditForm-input"
                                v-model="auditForm.bankAddr"></el-input>
                        </el-form-item>
                        <el-form-item label="获奖情况">
                            <el-input readonly type="textarea" :maxlength="1000"
                                :autosize="{ minRows: 10, maxRows: 10 }" class="auditForm-input"
                                v-model="auditForm.goodHis"></el-input>
                        </el-form-item>
                        <el-form-item label="主要事迹">
                            <el-input readonly type="textarea" :maxlength="1000"
                                :autosize="{ minRows: 10, maxRows: 10 }" class="auditForm-input"
                                v-model="auditForm.mainHis"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item label="查看">
                            <el-button size="mini" @click="myScoreVClick">查看学年成绩</el-button>
                            <el-button size="mini" @click="iamVClick">查看学年思想品德</el-button>
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item v-if="!isEmpty(auditForm.fdyComment)" label="辅导员审核意见">
                            <el-input readonly type="textarea" :maxlength="1000"
                                :autosize="{ minRows: 10, maxRows: 10 }" class="auditForm-input"
                                v-model="auditForm.fdyComment"></el-input>
                        </el-form-item>
                        <el-form-item v-if="!isEmpty(auditForm.deptComment)" label="学院审核意见">
                            <el-input readonly type="textarea" :maxlength="1000"
                                :autosize="{ minRows: 10, maxRows: 10 }" class="auditForm-input"
                                v-model="auditForm.deptComment"></el-input>
                        </el-form-item>
                        <el-form-item v-if="!isEmpty(auditForm.finalComment)" label="学工审核意见">
                            <el-input readonly type="textarea" :maxlength="1000"
                                :autosize="{ minRows: 10, maxRows: 10 }" class="auditForm-input"
                                v-model="auditForm.finalComment"></el-input>
                        </el-form-item>
                    </el-col>

                </el-row>

            </el-form>

            <el-dialog :visible.sync="iamV" title="学生思想品德" append-to-body :close-on-click-modal="false">
                <el-table :data="iam_count">
                    <el-table-column label="学年" prop="stuYearName" align="center" />
                    <el-table-column label="总记录数" prop="iamCount" align="center" />
                    <el-table-column label="加分数" prop="addCount" align="center" />
                    <el-table-column label="扣分数" prop="minusCount" align="center" />
                </el-table>
            </el-dialog>

            <el-dialog :visible.sync="myScoreV" title="学生成绩" append-to-body :close-on-click-modal="false">
                <el-table :data="score_list">
                    <el-table-column label="学年" prop="stuYearName" align="center" />
                    <el-table-column label="平均学分绩" prop="stuScore" align="center" />
                    <el-table-column label="综合素质总成绩" prop="cphScore" align="center" />
                    <el-table-column label="体能测试成绩" prop="sportScore" align="center" />
                    <el-table-column label="平均学分绩班级排名" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.stuClassRank + '/' + scope.row.classCount }}
                        </template>
                    </el-table-column>
                    <el-table-column label="综合素质总成绩班级排名" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.cphClassRank + '/' + scope.row.classCount }}
                        </template>
                    </el-table-column>
                    <el-table-column label="平均学分绩班级排名百分比" align="center">
                        <template slot-scope="scope">
                            {{ Math.round(scope.row.stuClassRank / scope.row.classCount * 10000) / 100 + "%" }}
                        </template>
                    </el-table-column>
                    <el-table-column label="学年综合素质测评班级排名百分比" align="center">
                        <template slot-scope="scope">
                            {{ Math.round(scope.row.cphClassRank / scope.row.classCount * 10000) / 100 + "%" }}
                        </template>
                    </el-table-column>
                </el-table>
                <el-table :data="count_list">
                    <el-table-column label="学年" prop="stuYearName" align="center" />
                    <el-table-column label="课程总门数" prop="courseCount" align="center" />
                    <el-table-column label="通过门数" prop="passCount" align="center" />
                    <el-table-column label="未通过门数" prop="unpassCount" align="center" />
                </el-table>


                <el-table :data="course_list" v-loading="course_loading">
                    <el-table-column label="学期" prop="termName" align="center" />
                    <el-table-column label="课程" prop="courseName" align="center" />
                    <el-table-column label="成绩" prop="courseScore" align="center" />
                    <el-table-column label="是否通过" align="center">
                        <template slot-scope="scope">
                            {{ scope.row.isPass == "true" ? "通过" : "未通过" }}
                        </template>
                    </el-table-column>
                </el-table>
                <pagination v-show="courseTotal > 0" :total="courseTotal" :page.sync="courseParams.pageNum"
                    :limit.sync="courseParams.pageSize" @pagination="listStuYearCourseScore" />
            </el-dialog>

        </el-dialog>

        <el-dialog title="导出学业奖学金" :visible.sync="jxjV">
            <el-select v-model="importForm.stuYearId" placeholder="请选择学年" clearable @keyup.enter.native="handleQuery">
                <el-option v-for="(v, i) in year_list" :key="i" :label="v.stuYearName" :value="v.id">
                </el-option>
            </el-select>
            <el-select @change="changeDept" v-model="importForm.deptId" placeholder="请选择学院" filterable clearable>
                <el-option v-for="(v, i) in dept_list" :key="i" :label="v.label" :value="v.value">
                </el-option>
            </el-select>
            <el-select v-model="importForm.majorId" placeholder="请先选择学院再选择专业" filterable clearable>
                <el-option v-for="(v, i) in major_list" :key="i" :label="v.majorName" :value="v.majorId">
                </el-option>
            </el-select>
            <div style="font-size: small;margin: 10px 0 10px 10px; color: red;">*学年是必选项，其余两项不选就默认导出全部。</div>
            <el-button @click="importJxj">导出</el-button>
        </el-dialog>

        <el-dialog title="导出三好学生" :visible.sync="shxsV">
            <el-select v-model="shxsForm.stuYearId" placeholder="请选择学年" clearable @keyup.enter.native="handleQuery">
                <el-option v-for="(v, i) in year_list" :key="i" :label="v.stuYearName" :value="v.id">
                </el-option>
            </el-select>
            <el-select @change="changeShxsDept" v-model="shxsForm.deptId" placeholder="请选择学院" filterable clearable>
                <el-option v-for="(v, i) in dept_list" :key="i" :label="v.label" :value="v.value">
                </el-option>
            </el-select>
            <el-select v-model="shxsForm.majorId" placeholder="请先选择学院再选择专业" filterable clearable>
                <el-option v-for="(v, i) in major_list" :key="i" :label="v.majorName" :value="v.majorId">
                </el-option>
            </el-select>
            <div style="font-size: small;margin: 10px 0 10px 10px; color: red;">*学年是必选项，其余两项不选就默认导出全部。</div>
            <el-button @click="importShxs">导出</el-button>
        </el-dialog>

        <el-dialog title="导出优秀学生干部" :visible.sync="yxbgV">
            <el-select v-model="yxbgForm.stuYearId" placeholder="请选择学年" clearable @keyup.enter.native="handleQuery">
                <el-option v-for="(v, i) in year_list" :key="i" :label="v.stuYearName" :value="v.id">
                </el-option>
            </el-select>
            <el-select @change="changeYxbgDept" v-model="yxbgForm.deptId" placeholder="请选择学院" filterable clearable>
                <el-option v-for="(v, i) in dept_list" :key="i" :label="v.label" :value="v.value">
                </el-option>
            </el-select>
            <el-select v-model="yxbgForm.majorId" placeholder="请先选择学院再选择专业" filterable clearable>
                <el-option v-for="(v, i) in major_list" :key="i" :label="v.majorName" :value="v.majorId">
                </el-option>
            </el-select>
            <div style="font-size: small;margin: 10px 0 10px 10px; color: red;">*学年是必选项，其余两项不选就默认导出全部。</div>
            <el-button @click="importYxbg">导出</el-button>
        </el-dialog>

        <el-dialog title="作废" :visible.sync="voidV">
            <el-input type="textarea" placeholder="请输入作废理由" v-model="voidForm.finalComment"></el-input>
            <el-button @click="voidApply">作废</el-button>
        </el-dialog>

        <el-dialog title="修改状态" :visible.sync="changeV">
            <el-radio-group v-model="changeForm.status">
                <el-radio :label="10">驳回</el-radio>
                <el-radio :label="11">拒绝</el-radio>
                <el-radio :label="6">通过</el-radio>
            </el-radio-group>
            <el-input type="textarea" placeholder="请输入理由" v-model="changeForm.finalComment"></el-input>
            <el-button @click="changeApply">修改</el-button>
        </el-dialog>


    </div>
</template>
<script>
import { isEmpty } from "@/api/helpFunc";
import {
    listAllAudit, lookDetail, listStuScoreClassRank, listStuYearCourseScore, countStuPass, countStuIam, deptAudit, importJxj,
    importShxs, importYxbg, applyStatus, voidApply, changeApply
} from "@/api/stuCQS/good/audit";
import lodash from "lodash";
import { listEnableYear as listYear } from "@/api/stuCQS/basedata/year";
import * as XLSX from 'xlsx';
import { workbook2blob, openDownloadDialog, file2Xce } from "@/api/helpFunc";
import { getDeptName } from "@/api/system/dept";
import { listMajors } from "@/api/stuCQS/basedata/majors";
import { listClass } from "@/api/stuCQS/basedata/class";


export default {
    name: "xw-audit",
    dicts: ['audius_detail_type'],
    data() {
        return {
            code_list: [
                {
                    name: "学业奖学金",
                    code: "XYJXJ"
                },
                {
                    name: "三好学生",
                    code: "SHXS"
                },
                {
                    name: "优秀学生干部",
                    code: "YXXSGB"
                }
            ],

            isEmpty,

            fullLoading: false,

            loading: false,
            table_data: [],
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                code: null,
                status: null,
                stuNo: "",
                stuName: "",
                deptId: null,
                majorId: null,
                classId: null
            },

            auditV: false,
            auditForm: {},
            material_list: [],

            score_list: [],
            myScoreV: false,
            course_list: [],
            courseParams: {
                pageNum: 1,
                pageSize: 10
            },
            courseTotal: 0,
            course_loading: false,

            count_list: [],

            iamV: false,
            iam_count: [],

            doForm: {
                auditId: null,
                status: null,
                common: ""
            },

            year_list: [],
            dept_list: [],
            major_list: [],
            jxjV: false,
            importForm: {
                stuYearId: null,
                deptId: null,
                majorId: null
            },

            shxsV: false,
            shxsForm: {
                stuYearId: null,
                deptId: null,
                majorId: null
            },

            yxbgV: false,
            yxbgForm: {
                stuYearId: null,
                deptId: null,
                majorId: null
            },
            applyStatus,
            voidV: false,
            voidForm: {
                applyId: null,
                finalComment: ""
            },
            search_major_list: [],
            search_class_list: [],


            changeV: false,
            changeForm: {
                finalComment: "",
                status: null,
                applyId: null
            }
        }
    },
    created() {
        this.listDept();
        this.listAllStuYear();
        this.getList();
    },
    methods: {
        async changeSearchMajor() {
            let sdata = {
                pageNum: 1,
                pageSize: 100,
                majorId: this.queryParams.majorId
            }
            let res = await listClass(sdata);
            if (res.code == 200) {
                this.search_class_list = [...res.rows];
            }
        },
        async changeApply() {
            let sdata = { ...this.changeForm };
            if (isEmpty(sdata.status)) {
                this.$message.info("请选择状态");
                return;
            }
            if (isEmpty(sdata.finalComment)) {
                this.$message.info("请输入理由");
                return;
            }

            this.fullLoading = true;
            let res = await changeApply(sdata);
            this.fullLoading = false;

            if (res.code == 200) {
                this.changeV = false;
                this.$message.success(res.msg);
                this.getList();
            }
        },
        changeVClick(row) {
            this.changeForm.applyId = row.applyId;
            this.changeV = true;
        },
        async voidApply() {
            let sdata = { ...this.voidForm };
            if (isEmpty(sdata.finalComment)) {
                this.$message.info("请输入作废理由");
                return;
            }
            this.fullLoading = true;
            let res = await voidApply(sdata);
            this.fullLoading = false;

            if (res.code == 200) {
                this.voidV = false;
                this.$message.success(res.msg);
                this.getList();
            }

        },
        voidVClick(row) {
            this.voidForm.applyId = row.applyId;
            this.voidV = true;
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        async changeDept() {
            let sdata = {
                collegeId: this.importForm.deptId,
                pageNum: 1,
                pageSize: 100
            }
            let res = await listMajors(sdata);
            this.major_list = [...res.rows];
        },
        async changeShxsDept() {
            let sdata = {
                collegeId: this.shxsForm.deptId,
                pageNum: 1,
                pageSize: 100
            }
            let res = await listMajors(sdata);
            this.major_list = [...res.rows];
        },
        async changeYxbgDept() {
            let sdata = {
                collegeId: this.yxbgForm.deptId,
                pageNum: 1,
                pageSize: 100
            }
            let res = await listMajors(sdata);
            this.major_list = [...res.rows];
        },
        async changeSearchDept() {
            let sdata = {
                collegeId: this.queryParams.deptId,
                pageNum: 1,
                pageSize: 100
            }
            let res = await listMajors(sdata);
            this.search_major_list = [...res.rows];
        },
        async listDept() {
            let res = await getDeptName();
            this.dept_list = [...res.data];
            console.log(res.data);
        },
        async importShxs() {
            if (isEmpty(this.shxsForm.stuYearId)) {
                this.$message.info("请选择学年");
                return;
            }
            let sdata = { ...this.shxsForm }
            let res = await importShxs(sdata);
            if (res.code == 200) {
                let data = res.data;

                const header = ['stuYearName', 'deptName', 'majorName', 'className', 'stuNo', 'stuName', 'typeName', 'applyStatus', 'importTime', 'teacherName'];
                const header_zh = {
                    'stuYearName': "学年",
                    "deptName": "学院",
                    "majorName": "专业",
                    "className": "班级",
                    "stuNo": "学号",
                    "stuName": "姓名",
                    "typeName": "奖项",
                    "applyStatus": "审核状态",
                    "importTime": "导出时间",
                    'teacherName': "辅导员"
                };

                const arrayWithHeader = [header_zh, ...data];

                var sheet1 = XLSX.utils.json_to_sheet(arrayWithHeader,
                    {
                        header: header,
                        skipHeader: true
                    });
                sheet1["!cols"] = [
                    { wch: 15 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 10 },
                    { wch: 10 },
                    { wch: 15 },
                    { wch: 15 },
                    { wch: 40 },
                    { wch: 40 }
                ];

                // 创建一个新的空的workbook
                var wb = XLSX.utils.book_new();
                // 为每一个工作簿设置名称并添加到workbook（excel表）中
                XLSX.utils.book_append_sheet(wb, sheet1, "三好学生名单");
                const workbookBlob = workbook2blob(wb);  // 辅助函数workbook2blob
                // 下载文档并添加文件名称
                openDownloadDialog(workbookBlob, "三好学生名单.xlsx");  // 辅助函数openDownloadDialog
            }
        },
        async importYxbg() {
            if (isEmpty(this.yxbgForm.stuYearId)) {
                this.$message.info("请选择学年");
                return;
            }
            let sdata = { ...this.yxbgForm }
            let res = await importYxbg(sdata);
            if (res.code == 200) {
                let data = res.data;

                const header = ['stuYearName', 'deptName', 'majorName', 'className', 'stuNo', 'stuName', 'typeName', 'applyStatus', 'importTime', 'teacherName'];
                const header_zh = {
                    'stuYearName': "学年",
                    "deptName": "学院",
                    "majorName": "专业",
                    "className": "班级",
                    "stuNo": "学号",
                    "stuName": "姓名",
                    "typeName": "奖项",
                    "applyStatus": "审核状态",
                    "importTime": "导出时间",
                    'teacherName': "辅导员"
                };

                const arrayWithHeader = [header_zh, ...data];

                var sheet1 = XLSX.utils.json_to_sheet(arrayWithHeader,
                    {
                        header: header,
                        skipHeader: true
                    });
                sheet1["!cols"] = [
                    { wch: 15 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 10 },
                    { wch: 10 },
                    { wch: 15 },
                    { wch: 15 },
                    { wch: 40 },
                    { wch: 40 }
                ];

                // 创建一个新的空的workbook
                var wb = XLSX.utils.book_new();
                // 为每一个工作簿设置名称并添加到workbook（excel表）中
                XLSX.utils.book_append_sheet(wb, sheet1, "优秀学生干部名单");
                const workbookBlob = workbook2blob(wb);  // 辅助函数workbook2blob
                // 下载文档并添加文件名称
                openDownloadDialog(workbookBlob, "优秀学生干部名单.xlsx");  // 辅助函数openDownloadDialog
            }
        },
        async importJxj() {
            if (isEmpty(this.importForm.stuYearId)) {
                this.$message.info("请选择学年");
                return;
            }
            let sdata = { ...this.importForm }
            let res = await importJxj(sdata);
            if (res.code == 200) {
                let data = res.data;

                const header = ['stuYearName', 'deptName', 'majorName', 'className', 'stuNo', 'stuName', 'typeName', 'applyStatus', 'bankCard', 'bankAddr', 'importTime', 'teacherName'];
                const header_zh = {
                    'stuYearName': "学年",
                    "deptName": "学院",
                    "majorName": "专业",
                    "className": "班级",
                    "stuNo": "学号",
                    "stuName": "姓名",
                    "typeName": "奖项",
                    "applyStatus": "审核状态",
                    "bankCard": "银行卡号",
                    "bankAddr": "开户行",
                    "importTime": "导出时间",
                    'teacherName': "辅导员"
                };

                const arrayWithHeader = [header_zh, ...data];

                var sheet1 = XLSX.utils.json_to_sheet(arrayWithHeader,
                    {
                        header: header,
                        skipHeader: true
                    });
                sheet1["!cols"] = [
                    { wch: 15 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 10 },
                    { wch: 10 },
                    { wch: 15 },
                    { wch: 20 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 40 },
                    { wch: 40 }
                ];

                // 创建一个新的空的workbook
                var wb = XLSX.utils.book_new();
                // 为每一个工作簿设置名称并添加到workbook（excel表）中
                XLSX.utils.book_append_sheet(wb, sheet1, "学业奖学金名单");
                const workbookBlob = workbook2blob(wb);  // 辅助函数workbook2blob
                // 下载文档并添加文件名称
                openDownloadDialog(workbookBlob, "学业奖学金名单.xlsx");  // 辅助函数openDownloadDialog
            }
        },
        jxjVClick() {
            this.listDept();
            this.jxjV = true;
        },
        shxsVClick() {
            this.listDept();
            this.shxsV = true;
        },
        yxbgVClick() {
            this.listDept();
            this.yxbgV = true;
        },

        async listAllStuYear() {
            let res = await listYear();
            this.year_list = [...res.rows];
        },


        async getList() {
            this.loading = true;
            let res = await listAllAudit(this.queryParams);
            this.loading = false;
            if (res.code == 200) {
                this.table_data = [...res.rows];
                this.total = res.total;
            }
        },
        async auditVClick(v) {
            let id = v.applyId;
            this.fullLoading = true;
            let res = await lookDetail(id);
            this.fullLoading = false;
            if (res.code == 200) {
                if (!isEmpty(res.data.material)) {
                    this.material_list = res.data.material.split(",");
                } else {
                    this.material_list = [];
                }
                this.auditForm = res.data;
                this.auditV = true;
            }
        },
        async countStuIam() {
            let stuNo = this.auditForm.stuNo;
            let res = await countStuIam(stuNo);
            if (res.code == 200) {
                this.iam_count = res.data;
            }
        },

        async countStuPass() {
            let stuNo = this.auditForm.stuNo;

            let res = await countStuPass(stuNo);
            if (res.code == 200) {
                this.count_list = [...res.data];
            }
        },
        async listStuYearCourseScore() {
            let stuNo = this.auditForm.stuNo;

            this.course_loading = true;
            let res = await listStuYearCourseScore(stuNo, this.courseParams);
            this.course_loading = false;

            if (res.code == 200) {
                this.course_list = [...res.rows];
                this.courseTotal = res.total;
            }
        },
        async listStuScoreClassRank() {
            let stuNo = this.auditForm.stuNo;
            let res = await listStuScoreClassRank(stuNo);
            if (res.code == 200) {
                this.score_list = lodash.cloneDeep(res.data);
            }
        },
        iamVClick() {
            this.countStuIam();
            this.iamV = true;
        },
        myScoreVClick() {
            this.countStuPass();
            this.listStuScoreClassRank();
            this.listStuYearCourseScore();
            this.myScoreV = true;
        },
        async doAudit() {
            let sdata = { ...this.doForm };
            if (isEmpty(sdata.status)) {
                this.$message.info("请选择是否通过");
                return;
            }
            if (isEmpty(sdata.common)) {
                this.$message.info("请填写审核意见");
                return;
            }
            sdata.auditId = parseInt(this.auditForm.auditId);
            this.fullLoading = true;
            let res = await deptAudit(sdata);
            this.fullLoading = false;
            if (res.code == 200) {
                this.getList();
                this.auditForm = {};
                this.doForm = {
                    auditId: null,
                    status: null,
                    common: ""
                };
                this.auditV = false;
                this.$message.success(res.msg);
            }
        }
    }
}

</script>
<style lang="scss" scoped>
.addForm-input {
    width: 400px;
}

.detail {
    .el-form-item {
        margin-bottom: 0px;
    }
}
</style>